*Purpose: This file prepares the separate files from the public Pew data for the analysis
///carried out in "Latinos' Fears of Deportation by Citizenship, 2007-2018." 

***SET WORKING DIRECTORY--------------------------------------------------------------------
**Make sure to have all dataset files in this working directory

cd "/Users/asadasad/Dropbox/Book - Legal Visibility/Chapters/Appendix - Pew Survey/Article/Analysis/Analysis of Pew Data"



***2007 DATA-------------------------------------------------------------------------------
*Rename variables (so they are consistent across surveys)*

use "2007.dta", clear

***Rename Variables ------------------------
** Case Identifier (id)

** Main Dependent Variable
fre qn33
recode qn33 (1=3 "Worries a lot about deportation") (2=2 "Worries some about deportation") (3=1 "Doesn't worry much about deportation") (4=0 "Doesn't worry at all about deportation") (8/9 =.), gen(worry)
label variable worry "Deportation Worries (ordered)"
tab worry, m

recode qn33 (1/2=1 "Worries a lot/some about deportation") (3/4=0 "Doesn't worry much/at all about deportation")  (8/9 =. ), gen(worry2)
tab worry2, m
label variable worry2 "Deportation Worries (binary)"

recode qn33 (1/4=0 "Answered") (8/9=1 "Refused/don't know"), gen(worry_missing)
label variable worry_missing "Deportation Worries (missing=1, non-missing=0)"

** Main Independent Variable

*All Citizens v. All Noncitizens

tab qn9
tab qn9, nolabel
recode qn9 (1=1 "U.S. Citizens") (2=0 "Noncitizens")  (8/9 = .), gen(citizen)
label variable citizen "Are you a citizen of the US?"
tab citizen,m 
rename qn5 bornusa
rename qn69 greencard
tab citizen, m

replace citizen = 1 if bornusa==1 | bornusa==2
tab citizen, m

**Alternative Independent Variables
*All Foreign Born v. All U.S. Born
	*0 = US born, 1 = foreign born
	
gen nativity=.
replace nativity=0 if bornusa==1
replace nativity=0 if bornusa==2
replace nativity=1 if bornusa==3
replace nativity=. if bornusa==98
replace nativity=. if bornusa==99
label define nativity_lab 1 "Foreign Born"  0 "U.S. Born" , replace
label values nativity nativity_lab
label variable nativity "Foreign Born vs U.S. Born"
tab nativity, missing

gen missing_nativity = 0
replace missing_nativity = 1 if nativity==.
tab missing_nativity
tab citizen nativity, col m

*Specific Legal Status
	*1=US BORN CITIZENS
	*2=NATURALIZED CITIZENS
	*3=PERMANENT RESIDENTS
	*4=NOT A CITZEN/RESIDENT

gen legal_status=.
replace legal_status=1 if nativity==0   
replace legal_status=2 if citizen==1 & nativity==1

replace legal_status=3 if citizen==0 & nativity==1 & greencard==1
replace legal_status=3 if citizen==. & nativity==1 & greencard==1

replace legal_status=4 if citizen==0 & nativity==1 & greencard==2
replace legal_status=4 if citizen==0 & nativity==1 & greencard==8
replace legal_status=4 if citizen==0 & nativity==1 & greencard==9
replace legal_status=4 if citizen==. & nativity==1 & greencard==8
replace legal_status=4 if citizen==. & nativity==1 & greencard==9
replace legal_status=4 if citizen==. & nativity==1 & greencard==2

label define l_status 1 "U.S.-born Citizens"  2 "Naturalized Citizens" 3 "Lawful Permanent Residents" 4 "Likely-Undocumented"  
label values legal_status l_status
label variable legal_status "Legal Status (4 level)"
tab legal_status, missing

replace citizen = 1 if legal_status==1 & citizen==.
replace citizen =1 if legal_status==2 & citizen==.
replace citizen =0 if legal_status==3 & citizen==.
replace citizen =0 if legal_status==4 & citizen==.
tab citizen, m

replace legal_status = 1 if citizen==1 & legal_status==.

tab citizen legal_status, col m

** Main Controls

*Age
rename qn50 age
tab age
tab age, nolabel
recode age (99=.)
recode age (98=.)
tab age, m
label variable age "Age"

gen missing_age=0 
replace missing_age=1 if age==.
tab age missing_age, missing

*Sex

tab qnd18
recode qnd18 (1=0 "Male") (2=1 "Female"), gen(sex)
tab sex, m
tab sex, nol

*Household Income
tab income
tab income, nolabel
recode income (1/15=0 "HH Income < $50,000") (21/27=1 "HH Income > $50,000") (98/99=.), gen(hhincome)
label variable hhincome "Household income"
tab hhincome, m 

gen missing_hhincome = 0
replace missing_hhincome = 1 if hhincome==.
tab missing_hhincome 

*Educational Attainment
tab qn51
tab qn51, nolabel
recode qn51 (1/2=0 "< High School") (3/4=1 "High School") (5/6=2 "Some College") (7/8=3 "College+") (9=.), gen(educ)
label variable educ "Education"
tab qn51 educ
tab educ, m

gen missing_educ = 0
replace missing_educ = 1 if educ==.
tab missing_educ

*Employment Status
tab qn52
tab qn52, nolabel
recode qn52 (1/2=1 "Employed") (3=0 "Unemployed") (8/9=.), gen(employment)
label variable employment "Employment Status"
tab employment

gen missing_employment = 0
replace missing_employment = 1 if employment==.
tab missing_employment

*Marital Status

tab qn48
tab qn48, nolabel
recode qn48 (1/2=1 "Married or Partnered") (3/6=0 "Unmarried or Unpartnered") (8/9=.), gen(marital)
label variable marital "Marital Status"
tab qn48 marital
tab marital, m

gen missing_marital = 0
replace missing_marital = 1 if marital==.
tab missing_marital

*Parental Status
tab qn49
tab qn49, nolabel
recode qn49 (1=1 "Parent") (2=0 "Not a Parent") (8/9=.), gen(parent)
tab qn49 parent
tab parent, m

gen missing_parent = 0
replace missing_parent = 1 if parent==.
tab missing_parent

*Political Party
tab qn17
tab qn17, nolabel
recode qn17 (1=0 "Republican") (2=1 "Democrat") (3/7=2 "Not a Republican or Democrat") (8/9 = .), gen(pparty)
label variable pparty "Political Party"
tab qn17 pparty

gen missing_pparty = 0
replace missing_pparty = 1 if pparty==.
tab missing_pparty

*Registered Voter
tab qn16 
tab qn16, nolabel missing
tab qn16 citizen, missing
tab citizen
tab citizen, nolabel
recode qn16 (1=1 "Registered Voter") (2/3=0 "Not a Registered Voter") (8/9=.) (.=.), gen(registeredvoter)
replace registeredvoter=0 if citizen==0
tab registeredvoter,m
label variable registeredvoter "Voter Registration Status"

tab registeredvoter citizen, col m

gen missing_registeredvoter = 0
replace missing_registeredvoter = 1 if registeredvoter==.
tab missing_registeredvoter

*Years Lived in USA

tab qn6
tab qn6, nolabel missing
tab qn6 bornusa, missing
tab qn6m
tab qn6m if qn6==0
tab qn6m, nolabel
replace qn6m=0 if qn6m==.
recode qn6m (98=.)
recode qn6m (99=.)
tab qn6m, m nol

gen yearslivedusa=qn6
replace yearslivedusa=qn6m/12 if yearslivedusa==0
recode yearslivedusa (98=.)
recode yearslivedusa (99=.)
replace yearslivedusa=age if bornusa==2
replace yearslivedusa=0 if yearslivedusa<1 & yearslivedusa !=.
tab yearslivedusa, missing
label variable yearslivedusa "Years Lived in USA"

gen missing_yrs=0 
replace missing_yrs=1 if yearslivedusa==.

*Household Adults

tab qn61, m
tab qn61, nol
*has refused option
rename qn61 hh_adults
replace hh_adults = . if hh_adults==99
tab hh_adults,m
label variable hh_adults "Number of Adults in Household"

gen missing_hh_adults = 0
replace missing_hh_adults = 1 if hh_adults==.
tab missing_hh_adults

*Survey Language

tab qn2
recode qn2 (1=0 "English Survey") (2=1 "Spanish Survey"), gen(intvlanguage)
tab intvlanguage, m

*Birth Country

tab qn5a, missing
tab qn5a nativity, missing
tab qn5a, nolabel

recode qn5a (.=0 "Born in USA")  (24=0 "Born in USA") (18=1 "Born in Mexico") (12=2 "Born in Central America") (17=2 "Born in Central America") (14=2 "Born in Central America") (1/11=3 "Born Outside USA, Mexico, Central America") ///
(13=3 "Born Outside USA, Mexico, Central America")(15/16=3 "Born Outside USA, Mexico, Central America") (18/23=3 "Other") (24/99=3 "Born Outside USA, Mexico, Central America"), gen(birthcountry)
tab qn5a birthcountry, missing
label variable birthcountry "Country of Birth"

*Census Region of Residence

rename sample03 census_region_res
gen svy_year = 2007
label variable svy_year "Year of Survey"

*Survey Weight

rename weight svy_weight
gen svy_weight2 = svy_weight*((0.1667)/(0.2340))

** Additional Controls

*Children in Household
tab qn49
tab qn49, nolabel

recode qn49 (1=1 "Child under 18 in HH")  (2=0 "No children in HH") (8/9=.), gen(child18)
label variable child18 "Child under 18 in Household"
tab child18, missing

gen missing_child18 = 0
replace missing_child18 =1 if child18== .
tab missing_child18

*Mother's Birthplace
tab qn7
tab qn7, nolabel missing
recode qn7 (1/2=0 "Mother Born in USA")  (3=1 "Mother Born Outside USA") (98/99=.), gen(m_born)
label variable m_born "Mother Born Outside the USA"
tab m_born, m

gen missing_m_born = 0
replace missing_m_born = 1 if m_born==.
tab missing_m_born

tab m_born bornusa

*Father's Birthplace
tab qn8
tab qn8, nolabel missing
recode qn8 (1/2=0 "Father Born in USA")  (3=1 "Father Born Outside USA") (98/99=.), gen(f_born)
label variable f_born "Father Born Outside the USA"
tab f_born

gen missing_f_born = 0
replace missing_f_born = 1 if f_born==.
tab missing_f_born

*Parents' Birthplace

gen parentborn=.
replace parentborn=0 if m_born==0&f_born==0
replace parentborn=1 if m_born==1|f_born==1
label variable parentborn "Was one of your parents born outside USA or Puerto Rico"
label define parentborn_labs 0 "No Foreign Born Parent"  1 "Foreign Born Parent" , replace
label values parentborn parentborn_labs

tab m_born f_born if parentborn==0
tab m_born f_born if parentborn==1

tab parentborn, m

gen missing_parentborn = 0
replace missing_parentborn = 1 if parentborn==.
tab missing_parentborn

*Occupation
tab  qn54 employment, missing
tab qn54, missing
tab qn54, nolabel missing

tab employment
tab employment,nolabel

recode qn54 (1/3=2 "White Collar Professional") (4/6=1 "Blue Collar Worker") (7/8=0 "Lower Skilled Worker") (97/99=.) (.=3 "Unemployed"),gen(occupation)
replace occupation=. if employment==.
replace occupation=. if employment==.
tab occupation, missing
tab occupation employment, missing

gen missing_occupation = 0
replace missing_occupation = 1 if occupation==.
tab missing_occupation

**Robustness Checks
*Discrimination 
	*During the last 5 years, have you, a family member, or close friend experienced
	/// discrimination because of your racial or ethnic background, or not? 

fre qn29
recode qn29 (1=1 "Yes, experienced race/ethnic discrimination") (2=0 "No, haven't experienced race/ethnic discrimination") (8/9 =.), gen(discrimination)
label variable discrimination "Race/Ethnic Discrimination"
fre discrimination

recode qn29 (1/2=0 "Answered") (8/9=1 "Refused/don't know"), gen(discrimination_missing)

*Discrimination Reason
	*We know that discrimination can result from many factors.  Which of the following do 
	///you consider the biggest cause of discrimination against (Hispanics/Latinos)?

fre qn32
recode qn32 (1=0 "Income or Education") (2=1 "Skin Color") (3=2 "Language Skills") (4=3 "Immigration Status") (8/9=.), gen(discrim_reason)
fre discrim_reason

recode qn32 (1/4=0 "Answered") (8/9=1 "Missing"), gen(discrim_reason_missing)

*Family heritage

fre qn4
recode qn4 (7/97 = 0 "Not Mexican/CA")(1=1 "Mexican or Central American") (2/4 = 0 "Not Mexican/CA") (5/6 = 1 "Mexican or Central American") (98/99 = .), gen(heritage)
tab heritage, m
label variable heritage "Family Heritage"

recode qn4 (1/97=0 "Answered") (98/99=1 "Missing"), gen(heritage_missing)
label variable heritage_missing "Family heritage 1==missing"

*Overall Deportation Rate
	**Use FY/total noncitizen population at risk of deportation 
gen deportations_overall = .
replace deportations_overall = (319382/21606126)
label variable deportations_overall "Overall Deportation Rate"

*Interior Deportation Rate
	**Use FY total/total noncitizen population at risk of deportation

gen deportations_interior = .
replace deportations_interior = (165694/21606126)
label variable deportations_interior "Interior Deportation Rate"

*Google Trends
	*Use trends data from months encompassing the Pew survey

gen gtrends_deport = .
replace gtrends_deport = 67.3
label variable gtrends_deport "Google Trends - Deportation"

* News articles mentioning "deport*"
	*Use data from months encompassing the Pew survey, divided by the total number of months for 
	///each survey and normalized to 100

gen news = .
replace news = 32.1
label variable news "News Mentions of Deport*"

keep id worry worry2 m_born f_born parentborn citizen child18 bornusa nativity legal_status age sex hhincome educ employment marital parent pparty  registeredvoter yearslivedusa  intvlanguage birthcountry census_region_res svy_year svy_weight hh_adults occupation discrimination discrimination_missing discrim_reason discrim_reason_missing heritage heritage_missing deportations_interior gtrends_deport deportations_overall svy_weight2 news 

save "2007_clean.dta", replace









*******2008 DATA---------------------------------------------------------------------
use "2008.dta", clear


***Rename Variables ------------------------
* Case Identifier
rename cati_id id

* Main Dependent Variable
*Participants were asked one of these questions
*Since they are so similar, combine them into a single question, worry

gen worry_c=qn38
replace worry_c=qn37 if qn38==. 

fre qn38
fre qn37
fre worry_c

recode worry_c (1=3 "Worries a lot about deportation") (2=2 "Worries some about deportation") (3=1 "Doesn't worry much about deportation") (4=0 "Doesn't worry at all about deportation") (8/9 =.), gen(worry)
label variable worry "Deportation Worries (ordered)"
tab worry, m

recode worry_c (1/2=1 "Worries a lot/some about deportation") (3/4=0 "Doesn't worry much/at all about deportation")  (8/9 =. ), gen(worry2)
recode worry_c (1/4=0 "Answered") (8/9=1 "Refused/don't know"), gen(worry_missing)
label variable worry2 "Deportation Worries (binary)"
tab worry2, m

tab worry_missing
label variable worry_missing "Deportation Worries (missing=1, non-missing=0)"

** Main Independent Variable
*All U.S. Citizens v. All Noncitizens

tab qn9
tab qn9, nolabel
recode qn9 (1=1 "U.S. Citizens") (2=0 "Noncitizens")  (8/9 = .), gen(citizen)
label variable citizen "Are you a citizen of the US?"
tab citizen
rename qn5 bornusa
rename qn79 greencard

replace citizen = 1 if bornusa==1 | bornusa==2

tab citizen,m

tab bornusa
tab greencard

tab citizen, nolabel
tab bornusa, nolabel
tab greencard, nolabel

*Foreign Born v. U.S. Born
*0 = us born, 1 = foreign born

gen nativity=.
replace nativity=0 if bornusa==1
replace nativity=0 if bornusa==2
replace nativity=1 if bornusa==3
replace nativity=. if bornusa==98
replace nativity=. if bornusa==99
label define nativity_lab 1 "Foreign Born"  0 "U.S. Born" , replace
label values nativity nativity_lab
label variable nativity "Foreign Born vs U.S. Born"
tab nativity, missing

replace citizen =1 if nativity==0

*legal status
*1=US BORN CITIZENS
*2=NATURALIZED CITIZENS
*3=PERMANENT RESIDENTS
*4=NOT A CITZEN/RESIDENT

gen legal_status=.
replace legal_status=1 if nativity==0   
replace legal_status=2 if citizen==1 & nativity==1

replace legal_status=3 if citizen==0 & nativity==1 & greencard==1
replace legal_status=3 if citizen==8 & nativity==1 & greencard==1
replace legal_status=3 if citizen==9 & nativity==1 & greencard==1

replace legal_status=4 if citizen==0 & nativity==1 & greencard==2
replace legal_status=4 if citizen==0 & nativity==1 & greencard==8
replace legal_status=4 if citizen==0 & nativity==1 & greencard==9
replace legal_status=4 if citizen==9 & nativity==1 & greencard==8
replace legal_status=4 if citizen==9 & nativity==1 & greencard==9
replace legal_status=4 if citizen==9 & nativity==1 & greencard==2

replace citizen = 1 if legal_status==1
replace citizen =1 if legal_status==2
replace citizen =0 if legal_status==3
replace citizen =0 if legal_status==4

label define l_status 1 "U.S.-born Citizens"  2 "Naturalized Citizens" 3 "Lawful Permanent Residents" 4 "Likely-Undocumented"  
label values legal_status l_status
label variable legal_status "Legal Status (4 level)"
tab legal_status, missing

replace citizen = 1 if legal_status==1 & citizen==.
replace citizen =1 if legal_status==2 & citizen==.
replace citizen =0 if legal_status==3 & citizen==.
replace citizen =0 if legal_status==4 & citizen==.
tab citizen, m

replace legal_status = 1 if citizen==1 & legal_status==.
tab citizen legal_status, col m
tab nativity legal_status, col m

tab legal_status greencard, col m

replace legal_status= 3 if greencard==1 & legal_status==.

replace nativity = 0 if legal_status==1 & nativity==.

** Main Controls
*Age
rename qn62 age
tab age
tab age, nolabel
recode age (99=.)
recode age (98=.)

gen missing_age=0 
replace missing_age=1 if age==.
tab age missing_age, missing

*Sex
tab qnd18
recode qnd18 (1=0 "Male") (2=1 "Female"), gen(sex)
tab sex, m
tab sex, nol

*Household Income
tab qn66
tab qn66, nolabel
recode qn66 (1/5=0 "HH Income < $50,000") (6/9=1 "HH Income > $50,000") (98/99=.), gen(hhincome)
tab qn66 hhincome

gen missing_hhincome = 0
replace missing_hhincome = 1 if hhincome==.
tab missing_hhincome 

*Educational Attainment
tab qn63
tab qn63, nolabel
recode qn63 (1/2=0 "< High School") (3/4=1 "High School") (5/6=2 "Some College") (7/8=3 "College+") (9=.), gen(educ)
label variable educ "Education"
tab qn63 educ, missing

gen missing_educ = 0
replace missing_educ = 1 if educ==.
tab missing_educ

*Employment
tab qn64
tab qn64, nolabel
recode qn64 (1/2=1 "Employed") (3=0 "Unemployed") (8/9=.), gen(employment)
label variable employment "Employment Status"
tab employment

gen missing_employment = 0
replace missing_employment = 1 if employment==.
tab missing_employment

*Marital Status
tab qn60
tab qn60, nolabel
recode qn60 (1/2=1 "Married or Partnered") (3/6=0 "Unmarried or Unpartnered") (8/9=.), gen(marital)
label variable marital "Marital Status"
tab qn60 marital

gen missing_marital = 0
replace missing_marital = 1 if marital==.
tab missing_marital

*Parental Status
tab qn61
tab qn61, nolabel
recode qn61 (1=1 "Parent") (2=0 "Not a Parent") (8/9=.), gen(parent)
tab qn61 parent

gen missing_parent = 0
replace missing_parent = 1 if parent==.
tab missing_parent

*Political Party
tab qn21
tab qn21, nolabel
recode qn21 (1=0 "Republican") (2=1 "Democrat") (3/7=2 "Not a Republican or Democrat") (8/9=.), gen(pparty)
label variable pparty "Political Party"
tab qn21 pparty

gen missing_pparty = 0
replace missing_pparty = 1 if pparty==.
tab missing_pparty

*Registered Voter
tab qn14
tab qn14, nolabel
tab qn14 citizen, missing
recode qn14 (1=1 "Registered Voter") (2=0 "Not a Registered Voter") (8/9=.) (.=.) , gen(registeredvoter)
replace registeredvoter=0 if citizen==0
tab registeredvoter
label variable registeredvoter "Voter Registration Status"

gen missing_registeredvoter = 0
replace missing_registeredvoter = 1 if registeredvoter==.
tab missing_registeredvoter

*Years Lived in USA
tab qn6
tab qn6, nolabel missing
tab qn6 bornusa, missing
tab qn6m
tab qn6m if qn6==0
tab qn6m, nolabel
replace qn6m=0 if qn6m==.
recode qn6m (98=.)
recode qn6m (99=.)
tab qn6m, nolabel

gen yearslivedusa=qn6
replace yearslivedusa=qn6m/12 if yearslivedusa==0
recode yearslivedusa (98=.)
recode yearslivedusa (99=.)
replace yearslivedusa=age if bornusa==2
replace yearslivedusa=0 if yearslivedusa<1 & yearslivedusa !=.
tab yearslivedusa, missing
label variable yearslivedusa "Years Lived in USA"

gen missing_yrs=0 
replace missing_yrs=1 if yearslivedusa==.

*Survey Language
tab qn2
recode qn2 (1=0 "English Survey") (2=1 "Spanish Survey"), gen(intvlanguage)
tab intvlanguage, m

recode qn5a (.=0 "Born in USA")  (24=0 "Born in USA") (18=1 "Born in Mexico") (12=2 "Born in Central America") (17=2 "Born in Central America") (14=2 "Born in Central America") (1/11=3 "Born Outside USA, Mexico, Central America") ///
(13=3 "Born Outside USA, Mexico, Central America")(15/16=3 "Born Outside USA, Mexico, Central America") (18/23=3 "Other") (24/99=3 "Born Outside USA, Mexico, Central America"), gen(birthcountry)
tab qn5a birthcountry, missing
label variable birthcountry "Country of Birth"

*Census Region of Residence
rename samp13 census_region_res
gen svy_year = 2008
rename weight svy_weight
gen svy_weight2 = svy_weight*((0.1667)/(0.2351))
label variable svy_year "Year of Survey"

**Additional Controls
*Household Adults
rename qn67 hh_adults
replace hh_adults = . if hh_adults==99

gen missing_hh_adults = 0
replace missing_hh_adults = 1 if hh_adults==.
tab missing_hh_adults

*Children in HH
tab qn61
tab qn61, nolabel
recode qn61 (1=1 "Child under 18 in HH")  (2=0 "No children in HH") (8/9=.), gen(child18)
label variable child18 "Child under 18 in Household"
tab child18, missing

gen missing_child18 = 0
replace missing_child18 =1 if child18== .
tab missing_child18

*Mother's Birthplace
tab qn7
tab qn7, nolabel missing
recode qn7 (1/2=0 "Mother Born in USA")  (3=1 "Mother Born Outside USA") (98/99=.), gen(m_born)
label variable m_born "Mother Born Outside the USA"
tab m_born

gen missing_m_born = 0
replace missing_m_born = 1 if m_born==.
tab missing_m_born

*Father's Birthplace
tab qn8
tab qn8, nolabel missing
recode qn8 (1/2=0 "Father Born in USA")  (3=1 "Father Born Outside USA") (98/99=.), gen(f_born)
label variable f_born "Father Born Outside the USA"
tab f_born

gen missing_f_born = 0
replace missing_f_born = 1 if f_born==.
tab missing_f_born

*Parents' Birthplace
gen parentborn=.
replace parentborn=0 if m_born==0&f_born==0
replace parentborn=1 if m_born==1|f_born==1
label variable parentborn "Was one of your parents born outside USA or Puerto Rico"
label define parentborn_labs 0 "No Foreign Born Parent"  1 "Foreign Born Parent" , replace
label values parentborn parentborn_labs

tab parentborn, missing

gen missing_parentborn = 0
replace missing_parentborn = 1 if parentborn==.
tab missing_parentborn

tab m_born f_born if parentborn==0
tab m_born f_born if parentborn==1

tab parentborn nativity, col m
tab parentborn legal_status, col m

*Occupation
tab qn65
tab qn65, nolabel missing

recode qn65 (1/3=2 "White Collar Professional") (4/6=1 "Blue Collar Worker") (7/8=0 "Lower Skilled Worker") (9=.) (97/99=.) (.=3 "Unemployed"),gen(occupation)
replace occupation=. if employment==8
replace occupation=. if employment==9
tab occupation, missing
tab occupation employment, missing

gen missing_occupation = 0
replace missing_occupation = 1 if occupation==.
tab missing_occupation

*Interviewer Race
tab qn83
recode qn83 (1=0 "White Interviewer") (2=1 "Black Interviewer") (3=2 "Hispanic Interviewer") (3=5 "Interviewer Not White, Black, or Hispanic"), gen(intvrace)
tab intvrace

**Robustness Checks

*Discrimination
*Have any of these things happened to you in the last year, or not?  
*qn36a: been stopped by police/other authorities and asked about immigration status
*qn36b: had trouble getting/keeping job because your Latino
*qn36c: had trouble finding/keeping housing

gen discrimination = .
replace discrimination = 1 if qn36a==1 | qn36b==1 | qn36c==1
replace discrimination = 0 if discrimination==. & qn36a==2
replace discrimination = 0 if discrimination==. & qn36b==2
replace discrimination = 0 if discrimination==. & qn36c==2
fre discrimination
label variable discrimination "Race/Ethnic Discrimination"

gen discrimination_missing = 0
replace discrimination_missing=1 if discrimination==.

*Heritage
fre qn4
recode qn4 (7 = 0 "Not Mexican/CA") (9/97 = 0 "Not Mexican/CA")(1=1 "Mexican or Central American") (2/4 = 0 "Not Mexican/CA")(8 = 0 "Not Mexican/CA")(5/6 = 1 "Mexican or Central American") (98/99 = .), gen(heritage)
tab heritage, m
label variable heritage "Family Heritage"
replace heritage = 1 if qn5a==18 & heritage==.
replace heritage = 0 if qn5a==16 & heritage==.
replace heritage = 0 if qn5a==9 & heritage==.
replace heritage = 0 if qn5a==7 & heritage==.
replace heritage = 0 if qn5a==4 & heritage==.
replace heritage = 0 if qn5a==97  & heritage==.

gen heritage_missing = 0
replace heritage_missing =1 if heritage==.
label variable heritage_missing "Family heritage 1==missing"

*google trends
gen gtrends_deport = .
replace gtrends_deport = 46.2


*overall deportation rate
gen deportations_overall = .
replace deportations_overall = (359795/21650834)

*interior deportation rate
*using FY/noncitizen population
gen deportations_interior = .
replace deportations_interior = (234770/21650834)

* News articles mentioning "deport*"
	*Use data from months encompassing the Pew survey, divided by the total number of months for 
	///each survey and normalized to 100

gen news = .
replace news = 19.4
label variable news "News Mentions of Deport*"

*** Keep ----------

keep id worry worry2 child18 f_born m_born parentborn citizen nativity legal_status age sex hhincome educ employment marital parent pparty registeredvoter yearslivedusa  intvlanguage birthcountry census_region_res svy_year svy_weight hh_adults  employment occupation intvrace discrimination discrimination_missing heritage heritage_missing gtrends_deport  deportations_interior deportations_overall svy_weight2 news

save "2008_clean.dta", replace











****2010 data*******

use "2010.dta", clear
***Rename Variables ------------------------
* Case Identifier (id)

* Main Dependent Variable
tab qn32
tab qn32, nolabel
recode qn32 (1=3 "Worries a lot about deportation") (2=2 "Worries some about deportation") (3=1 "Doesn't worry much about deportation") (4=0 "Doesn't worry at all about deportation") (8/9 =.), gen(worry)
label variable worry "Deportation Worries (ordered)"
tab worry, m

recode qn32 (1/2=1 "Worries a lot/some about deportation") (3/4=0 "Doesn't worry much/at all about deportation")  (8/9 =. ), gen(worry2)
tab worry2, m
label variable worry2 "Deportation Worries (binary)"

recode qn32 (1/4=0 "Answered") (8/9=1 "Refused/don't know"), gen(worry_missing)
label variable worry_missing "Deportation Worries (missing=1, non-missing=0)"

** Main Independent Variables
*All Citizens v. All Noncitizens

tab qn9
tab qn9, nolabel
recode qn9 (1=1 "U.S. Citizens") (2=0 "Noncitizens")  (8/9 = .), gen(citizen)
label variable citizen "Are you a citizen of the US?"
tab citizen,m 
rename qn4 bornusa
rename qn79 greencard
tab citizen, m

replace citizen = 1 if bornusa==1 | bornusa==2
tab citizen, m

*All Foreign Born v. All US Born
*0 = US born, 1 = foreign born
gen nativity=.
replace nativity=0 if bornusa==1
replace nativity=0 if bornusa==2
replace nativity=1 if bornusa==3
replace nativity=. if bornusa==8
replace nativity=. if bornusa==9
label define nativity_lab 1 "Foreign Born"  0 "U.S. Born" , replace
label values nativity nativity_lab
label variable nativity "Foreign Born vs U.S. Born"
tab nativity, missing

gen missing_nativity = 0
replace missing_nativity = 1 if nativity==.
tab missing_nativity

tab citizen nativity, col m

*legal status
*1=US BORN CITIZENS
*2=NATURALIZED CITIZENS
*3=PERMANENT RESIDENTS
*4=NOT A CITZEN/RESIDENT

gen legal_status=.
replace legal_status=1 if nativity==0   
replace legal_status=2 if citizen==1 & nativity==1

replace legal_status=3 if citizen==0 & nativity==1 & greencard==1
replace legal_status=3 if citizen==. & nativity==1 & greencard==1

replace legal_status=4 if citizen==0 & nativity==1 & greencard==2
replace legal_status=4 if citizen==0 & nativity==1 & greencard==8
replace legal_status=4 if citizen==0 & nativity==1 & greencard==9
replace legal_status=4 if citizen==. & nativity==1 & greencard==8
replace legal_status=4 if citizen==. & nativity==1 & greencard==9
replace legal_status=4 if citizen==. & nativity==1 & greencard==2

label define l_status 1 "U.S.-born Citizens"  2 "Naturalized Citizens" 3 "Lawful Permanent Residents" 4 "Likely-Undocumented"  
label values legal_status l_status
label variable legal_status "Legal Status (4 level)"
tab legal_status, missing

replace citizen = 1 if legal_status==1 & citizen==.
replace citizen =1 if legal_status==2 & citizen==.
replace citizen =0 if legal_status==3 & citizen==.
replace citizen =0 if legal_status==4 & citizen==.
tab citizen, m

replace legal_status = 1 if citizen==1 & legal_status==.

tab citizen legal_status, col m

**Main Controls
*Age
rename qn77 age
tab age
tab age, nolabel
recode age (99=.)
tab age, m
label variable age "Age"

gen missing_age=0 
replace missing_age=1 if age==.
tab age missing_age, missing

*Sex
tab gender
recode gender (1=0 "Male") (2=1 "Female"), gen(sex)
tab sex, m
tab sex, nol

*Household Income
rename qn78 income
tab income
tab income, nolabel
recode income (1/5=0 "HH Income < $50,000") (6/9=1 "HH Income > $50,000") (98/99=.), gen(hhincome)
label variable hhincome "Household income"
tab hhincome, m 

gen missing_hhincome = 0
replace missing_hhincome = 1 if hhincome==.
tab missing_hhincome 

*Educational Attainment
tab qn75
tab qn75, nolabel
recode qn75 (1/2=0 "< High School") (3=1 "High School") (4/5=2 "Some College") (6/7=3 "College+") (8/9=.), gen(educ)
label variable educ "Education"
tab qn75 educ
tab educ, m

gen missing_educ = 0
replace missing_educ = 1 if educ==.
tab missing_educ

*Employed
tab qn69
tab qn69, nolabel
recode qn69 (1/2=1 "Employed") (3=0 "Unemployed") (8/9=.), gen(employment)
label variable employment "Employment Status"
tab employment

gen missing_employment = 0
replace missing_employment = 1 if employment==.
tab missing_employment

*Marital Status
tab qn72
tab qn72, nolabel
recode qn72 (1/2=1 "Married or Partnered") (3/6=0 "Unmarried or Unpartnered") (8/9=.), gen(marital)
label variable marital "Marital Status"
tab qn72 marital
tab marital, m

gen missing_marital = 0
replace missing_marital = 1 if marital==.
tab missing_marital

*Parental Status
tab qn71
tab qn71, nolabel
recode qn71 (1=1 "Parent") (2=0 "Not a Parent") (8/9=.), gen(parent)
tab qn71 parent
tab parent, m

gen missing_parent = 0
replace missing_parent = 1 if parent==.
tab missing_parent

*Political Party
tab qn66,m
tab qn66, nolabel
recode qn66 (1=0 "Republican") (2=1 "Democrat") (3/4=2 "Not a Republican or Democrat") (8/9 = .), gen(pparty)
label variable pparty "Political Party"
tab qn66 pparty

gen missing_pparty = 0
replace missing_pparty = 1 if pparty==.
tab missing_pparty

*Registered Voter
tab qn67 
tab qn67, nolabel missing
tab qn67 citizen, missing
tab citizen
tab citizen, nolabel
recode qn67 (1=1 "Registered Voter") (2/3=0 "Not a Registered Voter") (8/9=.) (.=.), gen(registeredvoter)
replace registeredvoter=0 if citizen==0 & registeredvoter==.
tab registeredvoter,m
label variable registeredvoter "Voter Registration Status"

tab registeredvoter citizen, col m

gen missing_registeredvoter = 0
replace missing_registeredvoter = 1 if registeredvoter==.
tab missing_registeredvoter

*Years Lived USA
tab qn6m
tab qn6m, nolabel
replace qn6m=0 if qn6m==.
recode qn6m (98=.)
recode qn6m (99=.)
tab qn6m, m nol

gen yearslivedusa=qn6y
replace yearslivedusa=qn6m/12 if yearslivedusa==. & qn6m !=.
replace yearslivedusa=age if bornusa==2
replace yearslivedusa=0 if yearslivedusa<1 & yearslivedusa !=.
tab yearslivedusa, missing
label variable yearslivedusa "Years Lived in USA"

gen missing_yrs=0 
replace missing_yrs=1 if yearslivedusa==.

*Survey Language
tab Primary_Language
tab Primary_Language, nol
recode Primary_Language (1/2=0 "English Survey") (3=1 "Spanish Survey"), gen(intvlanguage)
tab intvlanguage, m

*Country of Birth
tab qn5, missing
tab qn5 nativity, missing
tab qn5, nolabel

replace nativity = 1 if nativity==. & qn5==18

recode qn5 (.=0 "Born in USA")  (24=0 "Born in USA") (18=1 "Born in Mexico") (12=2 "Born in Central America") (17=2 "Born in Central America") (14=2 "Born in Central America") (1/11=3 "Born Outside USA, Mexico, Central America") ///
(13=3 "Born Outside USA, Mexico, Central America")(15/16=3 "Born Outside USA, Mexico, Central America") (18/23=3 "Other") (24/99=3 "Born Outside USA, Mexico, Central America"), gen(birthcountry)
tab qn5 birthcountry, missing
label variable birthcountry "Country of Birth"

*Knows someone who was deported
fre qn33
recode qn33 (1=1 "Yes") (2=0 "No")  (8/9 = .), gen(deported)
label variable deported "Personally know someone detained or deported"
fre deported

*Census Region of Residence
rename sample20 census_region_res
gen svy_year = 2010
label variable svy_year "Year of Survey"

*Survey Weight
rename weight svy_weight
gen svy_weight2 = svy_weight*((0.1667)/(0.1588))

**Additional Controls
*Household Adults
tab qns1, m
tab qns1, nol
*has refused option
rename qns1 hh_adults
replace hh_adults = . if hh_adults==99
tab hh_adults,m
replace hh_adults = qnhh1 if hh_adults==.
tab hh_adults, nol
replace hh_adults = . if hh_adults==99
label variable hh_adults "Number of Adults in Household"

gen missing_hh_adults = 0
replace missing_hh_adults = 1 if hh_adults==.
tab missing_hh_adults

*Children in Household
tab qn71
tab qn71, nolabel

recode qn71 (1=1 "Child under 18 in HH")  (2=0 "No children in HH") (8/9=.), gen(child18)
label variable child18 "Child under 18 in Household"
tab child18, missing

gen missing_child18 = 0
replace missing_child18 =1 if child18== .
tab missing_child18

*Mother's Birthplace

tab qn7
tab qn7, nolabel missing
recode qn7 (1/2=0 "Mother Born in USA")  (3=1 "Mother Born Outside USA") (8=.), gen(m_born)
label variable m_born "Mother Born Outside the USA"
tab m_born, m

gen missing_m_born = 0
replace missing_m_born = 1 if m_born==.
tab missing_m_born

tab m_born bornusa

*Father's Birthplace

tab qn8
tab qn8, nolabel missing
recode qn8 (1/2=0 "Father Born in USA")  (3=1 "Father Born Outside USA") (8=.), gen(f_born)
label variable f_born "Father Born Outside the USA"
tab f_born

gen missing_f_born = 0
replace missing_f_born = 1 if f_born==.
tab missing_f_born

*Parents' Birthplace
gen parentborn=.
replace parentborn=0 if m_born==0&f_born==0
replace parentborn=1 if m_born==1|f_born==1
label variable parentborn "Was one of your parents born outside USA or Puerto Rico"
label define parentborn_labs 0 "No Foreign Born Parent"  1 "Foreign Born Parent" , replace
label values parentborn parentborn_labs

tab m_born f_born if parentborn==0
tab m_born f_born if parentborn==1

tab parentborn, m

gen missing_parentborn = 0
replace missing_parentborn = 1 if parentborn==.
tab missing_parentborn

**Robustness Checks
*Discrimination 
	* In general, do you think discrimination against (HISPANICS/LATINOS) is a major problem, minor problem, or not a problem in preventing (HISPANICS/LATINOS) in general from succeeding in America?

fre qn15
recode qn15 (3=0 "Not a Problem") (1/2=1 "Major or Minor Problem") (8/9 =. ), gen(discrim_problem)
fre discrim_problem
label variable discrim_problem "Discrimination a Problem? (binary)"

recode qn15 (0/2=0 "Answered") (8/9 =1 "Refused/Don't Know"), gen(discrim_problem_missing)

	*During the last 5 years, have you, a family member, or close friend experienced
	/// discrimination because of your racial or ethnic background, or not? 

fre qn17
recode qn17 (1=1 "Yes, experienced race/ethnic discrimination") (2=0 "No, haven't experienced race/ethnic discrimination") (8/9 =.), gen(discrimination)
label variable discrimination "Race/Ethnic Discrimination"
fre discrimination

recode qn17 (1/2=0 "Answered") (8/9=1 "Refused/don't know"), gen(discrimination_missing)

	*We know that discrimination can result from many factors.  Which of the following do 
	///you consider the biggest cause of discrimination against (Hispanics/Latinos)?

fre qn16
recode qn16 (1=0 "Income or Education") (2=1 "Skin Color") (3=2 "Language Skills") (4=3 "Immigration Status") (8/9=.), gen(discrim_reason)
fre discrim_reason

recode qn16 (1/4=0 "Answered") (8/9=1 "Missing"), gen(discrim_reason_missing)

*Heritage

fre qn3
recode qn3 (7/97 = 0 "Not Mexican/CA")(1=1 "Mexican") (2/4 = 0 "Not Mexican/CA") (5/6 = 1 "Mexican or Central American") (98/99 = .), gen(heritage)
tab heritage, m
label variable heritage "Family Heritage"

fre qn3x
replace heritage = 1 if heritage==. & qn3x==14 | qn3x==17 | qn3x==19
replace heritage = 0 if heritage==. & qn3x !=14 & qn3x !=17  & qn3 !=19 & qn3 !=97 & qn3x !=99

gen heritage_missing = 0
replace heritage_missing = 1 if heritage==.
label variable heritage_missing "Family heritage 1==missing"
tab heritage,m
tab heritage_missing

*Overall Deportation Rate
gen deportations_overall = .
replace deportations_overall = (382461/22021138)

*Interior Deportation Rate
*using previous FY/noncitizen population
gen deportations_interior = .
replace deportations_interior = (229235/22021138)

*Google Trends
gen gtrends_deport = .
replace gtrends_deport = 44.2

* News articles mentioning "deport*"
	*Use data from months encompassing the Pew survey, divided by the total number of months for 
	///each survey and normalized to 100

gen news = .
replace news = 24.8
label variable news "News Mentions of Deport*"

keep id worry worry2 m_born f_born parentborn citizen child18 bornusa nativity legal_status age sex hhincome educ employment marital parent pparty  registeredvoter yearslivedusa  intvlanguage birthcountry census_region_res svy_year svy_weight hh_adults discrim_problem discrim_problem_missing discrimination discrimination_missing discrim_reason discrim_reason_missing heritage heritage_missing gtrends_deport deportations_interior deportations_overall svy_weight2 deported news

save "2010_clean.dta", replace






















*****2013 DATA--------------------------------------------------------------------------
use "2013.dta", clear


***Rename Variables ------------------------
* Case Identifier
rename ID id

* Main Dependent Variable

fre im34

recode im34 (1=3 "Worries a lot about deportation") (2=2 "Worries some about deportation") (3=1 "Doesn't worry much about deportation") (4=0 "Doesn't worry at all about deportation") (9 =.), gen(worry)
label variable worry "Deportation Worries (ordered)"
tab worry, m

recode im34 (1/2=1 "Worries a lot/some about deportation") (3/4=0 "Doesn't worry much/at all about deportation")  (9 =. ), gen(worry2)
label variable worry2 "Deportation Worries (binary)"

recode im34 (1/4=0 "Answered") (9=1 "Refused/don't know"), gen(worry_missing)
label variable worry_missing "Deportation Worries (missing=1, non-missing=0)"

tab worry, missing
tab worry2,m
tab worry_missing





**Main Independent Variables
*All Citizens v. All Noncitizens

fre imqn9
tab imqn9, nolabel
recode imqn9 (1=1 "U.S. Citizens") (2=0 "Noncitizens")  (9 = .), gen(citizen)
label variable citizen "Are you a citizen of the US?"
tab citizen, m

rename imqn4 bornusa
fre bornusa

replace citizen = 1 if bornusa==1 | bornusa==2

tab citizen, m
tab bornusa

tab citizen, nolabel
tab bornusa, nolabel

fre citizen bornusa, missing

*All Foreign Born v. All US Born
*0 = us born, 1 = foreign born
gen nativity=.
replace nativity=0 if bornusa==1
replace nativity=0 if bornusa==2
replace nativity=1 if bornusa==3
replace nativity=. if bornusa==9
label define nativity_lab 1 "Foreign Born"  0 "U.S. Born" , replace
label values nativity nativity_lab
label variable nativity "Foreign Born vs U.S. Born"
tab nativity, missing

replace citizen=1 if nativity==0

*Legal Status
*No information on whether noncitizens are LPRs or likely-undocumented in this year.
gen legal_status=.
fre nativity
fre citizen
replace legal_status=1 if nativity==0   
replace legal_status=2 if citizen==1 & nativity==1
tab legal_status, m

**Main Controls
*Age
tab age
tab age, nolabel
recode age (99=.)

gen missing_age=0 
replace missing_age=1 if age==.
tab age missing_age, missing

*Sex
recode s5 (1=0 "Male") (2=1 "Female"), gen(sex)
tab sex, m
tab sex, nol

*Financial Situation
tab finsit 
tab finsit, nol

recode finsit (4=0 "Poor financial situation") (3=1 "Fair financial situation") (2=2 "Good financial situation") (1=3 "Excellent financial situation") (9=.), gen(hhincome2)
label define hhincome2_lab 0 "Poor Financial Situation" 1 "Fair Financial Situation" 2 "Good Financial Situation" 3 "Excellent Financial Situation" 9 "Unknown or Refused Financial Situation", replace
label values hhincome2 hhincome2_lab

gen missing_hhincome2 = 0
replace missing_hhincome2 = 1 if hhincome2==.
tab missing_hhincome2

tab hhincome2,m

*Political Party
tab party
tab party, nolabel
recode party (1=0 "Republican") (2=1 "Democrat") (3/9=2 "Not a Republican or Democrat"), gen(pparty)
label variable pparty "Political Party"
tab party pparty

gen missing_pparty = 0
replace missing_pparty = 1 if pparty==.
tab missing_pparty

*Registered Voter
tab rega, missing 
tab rega, nolabel
tab rega citizen, missing
recode rega (1/2=1 "Registered Voter") (3/4=0 "Not a Registered Voter") (9=.) (.=.) , gen(registeredvoter)
replace registeredvoter=0 if citizen==0
tab registeredvoter
label variable registeredvoter "Voter Registration Status"

gen missing_registeredvoter = 0
replace missing_registeredvoter = 1 if registeredvoter==.
tab missing_registeredvoter

*Years Lived in USA
tab imq6y
tab imq6y, missing nolabel
tab imq6m 
tab imq6m 
tab imq6y bornusa, missing
tab imq6y if imq6m==2

gen yearslivedusa= imq6y 
replace yearslivedusa=age if bornusa==2
replace yearslivedusa=imq6m/12 if yearslivedusa==.
replace yearslivedusa=0 if yearslivedusa<1 & yearslivedusa !=.
tab yearslivedusa, missing
label variable yearslivedusa "Years Lived in USA"

gen missing_yrs=0 
replace missing_yrs=1 if yearslivedusa==.

*Survey Language
encode intlan, gen(intvlanguage2)
tab intvlanguage2
tab intvlanguage2, nolabel
recode intvlanguage2 (2=1 "Spanish Survey") (1=0 "English Survey"), gen(intvlanguage)
tab intvlanguage
label define intv_labels 0 "English"  1 "Spanish" , replace
label values intvlanguage intv_labels
tab  intvlanguage

*Educational Attainment
tab imeduc
tab imeduc, nolabel
recode imeduc (1/2=0 "< High School") (3=1 "High School") (4/5=2 "Some College") (6/8=3 "College+") (9=.), gen(educ)
tab imeduc educ, missing

gen missing_educ = 0
replace missing_educ = 1 if educ==.
tab missing_educ

*Birthplace
tab imqn5 
tab imqn5, nolabel
tab imqn5 nativity, missing
recode imqn5 (.=0 "Born in USA")  (24=0 "Born in USA") (18=1 "Born in Mexico") (12=2 "Born in Central America") (17=2 "Born in Central America") (14=2 "Born in Central America") (1/11=3 "Born Outside USA, Mexico, Central America") ///
(13=3 "Born Outside USA, Mexico, Central America")(15/16=3 "Born Outside USA, Mexico, Central America") (18/23=3 "Other") (24/99=3 "Born Outside USA, Mexico, Central America"), gen(birthcountry)
tab imqn5 birthcountry
label variable birthcountry "Country of Birth"

*Census Region of Residence
destring samp20, gen(census_region_res)
recast double census_region_res
label define census_regions_labels2013 1 "Northeast"  2 "North Central" 3 "South" 4 "West"  
label values census_region_res census_regions_labels2013
tab census_region_res

gen svy_year = 2013
rename weight svy_weight
gen svy_weight2 = svy_weight*((0.1667)/(0.0819))
label variable svy_year "Year of Survey"

**Additional Controls
*Household Adults
tab s1, missing
tab  hh1 s1, missing
tab hh1, missing 
tab hh1, nolabel
recode hh1 (99=.)
tab hh1

gen  hh_adults=s1
tab hh_adults, missing
replace hh_adults=hh1 if hh_adults==.
tab hh_adults, missing
sum hh_adults

gen missing_hh_adults = 0
replace missing_hh_adults = 1 if hh_adults==.
tab missing_hh_adults

*Knowledge or Experience with Immigration System
tab im29
tab im32
tab im33

gen immsyst = .
replace immsyst = 0 if im29==3 | im32==2 | im33==2
replace immsyst = 1 if im29==1 | im29==2 | im32==1 | im33==1
label variable immsyst "Personal or Family Knowledge of or Experience with U.S. Immigration System"
label define immsyst 0 "No Knowledge of or Experience with U.S. Immigration System" 1 "Knowledge of or Experience with U.S. Immigration System"
label values immsyst immsyst
drop im29 im32 im33

tab immsyst

**Robustness Checks
*Heritage
fre imqn3
recode imqn3 (7/97 = 0 "Not Mexican/CA")(1=1 "Mexican or Central American") (2/4 = 0 "Not Mexican/CA")(5/6 = 1 "Mexican or Central American") (98/99 = .), gen(heritage)
tab heritage, m
label variable heritage "Family Heritage"

fre imqn3oth
replace heritage = 1 if imqn3oth==14 | imqn3oth==17 & heritage==.
replace heritage = 0 if imqn3oth !=14 & imqn3oth !=17 & heritage==.

gen heritage_missing = 0
replace heritage_missing =1 if heritage==.
label variable heritage_missing "Family heritage 1==missing"

*Google Trends
gen gtrends_deport = .
replace gtrends_deport = 42.3

*Overall Deportation Rate
gen deportations_overall = .
replace deportations_overall = (432281/22135003)

*Interior Deportation Rate
*using FY/noncitizen population
gen deportations_interior = .
replace deportations_interior = (133551/22135003)

* News articles mentioning "deport*"
	*Use data from months encompassing the Pew survey, divided by the total number of months for 
	///each survey and normalized to 100

gen news = .
replace news = 21.3
label variable news "News Mentions of Deport*"

*** Keep --------------

keep id worry worry2 citizen nativity legal_status sex age hhincome2 educ pparty registeredvoter yearslivedusa  intvlanguage birthcountry census_region_res svy_year svy_weight hh_adults immsyst heritage heritage_missing deportations_interior gtrends_deport  deportations_overall svy_weight2 news

save "2013_clean.dta", replace














****2017---------------------------------------------------------------------
use "2017.dta", clear

* Case Identifier
rename case_id id

* Main Dependent Variable
tab vote4
tab vote4, nolabel

recode vote4 (1=3 "Worries a lot about deportation") (2=2 "Worries some about deportation") (3=1 "Doesn't worry much about deportation") (4=0 "Doesn't worry at all about deportation") (8/9 =.), gen(worry)
label variable worry "Deportation Worries (ordered)"
tab worry, m

recode vote4 (1/2=1 "Worries a lot/some about deportation") (3/4=0 "Doesn't worry much/at all about deportation")  (8/9 =. ), gen(worry2)
tab worry2, m

recode vote4 (1/4=0 "Answered") (8/9=1 "Refused/don't know"), gen(worry_missing)
label variable worry_missing "Deportation Worries (missing=1, non-missing=0)"

tab worry, missing
tab worry2, m
tab worry_missing

**Main Independent Variables
*All Citizens v. All Noncitizens
tab vote9
tab vote9, nolabel
recode vote9 (1=1 "U.S. Citizens") (2=0 "Noncitizens")  (8/9 = .), gen(citizen)
label variable citizen "Are you a citizen of the US?"
tab citizen,m

rename bornus bornusa
rename vote10 greencard

replace citizen = 1 if bornusa==1 | bornusa==2

tab citizen
tab citizen, nolabel

tab bornusa
tab bornusa, nolabel

tab citizen bornusa, missing

tab greencard
tab greencard, nolabel

*All Foreign Born v. All US Born
*0 = us born, 1 = foreign born
gen nativity=.
replace nativity=0 if bornusa==1
replace nativity=0 if bornusa==2
replace nativity=1 if bornusa==3
replace nativity=. if bornusa==8
replace nativity=. if bornusa==9

label define nativity_lab 1 "Foreign Born"  0 "U.S. Born" , replace
label values nativity nativity_lab
label variable nativity "Foreign Born vs U.S. Born"
tab nativity, missing

replace citizen = 1 if nativity==0

*Legal Status
gen legal_status=.
replace legal_status=1 if nativity==0   
replace legal_status=2 if citizen==1 & nativity==1

replace legal_status=3 if citizen==0 & nativity==1 & greencard==1
replace legal_status=3 if citizen==8 & nativity==1 & greencard==1
replace legal_status=3 if citizen==9 & nativity==1 & greencard==1

replace legal_status=4 if citizen==0 & nativity==1 & greencard==2
replace legal_status=4 if citizen==0 & nativity==1 & greencard==8
replace legal_status=4 if citizen==0 & nativity==1 & greencard==9
replace legal_status=4 if citizen==8 & nativity==1 & greencard==8
replace legal_status=4 if citizen==9 & nativity==1 & greencard==8
replace legal_status=4 if citizen==8 & nativity==1 & greencard==9
replace legal_status=4 if citizen==9 & nativity==1 & greencard==9
replace legal_status=4 if citizen==9 & nativity==1 & greencard==2
replace legal_status=4 if citizen==8 & nativity==1 & greencard==2
replace legal_status=4 if citizen==8 & nativity==1 & greencard==.
replace legal_status=4 if citizen==9 & nativity==1 & greencard==.

label define l_status 1 "U.S.-born Citizens"  2 "Naturalized Citizens" 3 "Lawful Permanent Residents" 4 "Likely-Undocumented"  
label values legal_status l_status
label variable legal_status "Legal Status (4 level)"
tab legal_status, missing

replace citizen = 1 if legal_status==1 & citizen==.
replace citizen =1 if legal_status==2 & citizen==.
replace citizen =0 if legal_status==3 & citizen==.
replace citizen =0 if legal_status==4 & citizen==.
tab citizen, m

replace legal_status = 1 if citizen==1 & legal_status==.

tab citizen legal_status, col m

**Main Controls
*Age
tab age
tab age, nolabel
recode age (99=.)

gen missing_age=0 
replace missing_age=1 if age==.
tab age missing_age, missing

*Parental Status
tab parent, missing
tab parent, nolabel
egen parent_old= group(parent)
tab parent_old
recode parent (1=1 "Parent") (2=0 "Not a Parent") (8/9=.), gen(parent2)
tab parent parent2, missing
drop parent
gen parent=parent2
tab parent,m
drop parent2
label define parent_labels 1 "Parent"  0 "Not a Parent" , replace
label values parent parent_labels
tab parent,m

gen missing_parent = 0
replace missing_parent = 1 if parent==.
tab missing_parent

*Sex
rename sex Sex
recode Sex (1=0 "Male") (2=1 "Female"), gen(sex)
tab sex, m
tab sex, nol

*Number in Household  
tab totper
tab totper, nolabel
recode totper (1/4=0 "< 5 People in HH") (5/8=1 "> 5 People in HH") (9=.), gen (hhsize)
label variable hhsize "Household Size"
tab totper hhsize

gen missing_hhsize = 0
replace missing_hhsize = 1 if hhsize==.
tab missing_hhsize

*Household Income 
tab income
tab income, nolabel
recode income (1/5=0 "HH Income < $50,000") (6/8=1 "HH Income > $50,000") (9=0 "HH Income < $50,000") (10/15=1 "HH Income > $50,000")  (98/99=.), gen(hhincome)
label variable hhincome "Income"
tab hhincome
tab  income hhincome

gen missing_hhincome = 0
replace missing_hhincome = 1 if hhincome==.
tab missing_hhincome 

*Employment
tab employ
tab employ, nolabel
recode employ (1/2=1 "Employed") (3/8=0 "Unemployed") (9=.), gen(employment)
label variable employment "Employment Status"
tab employment

gen missing_employment = 0
replace missing_employment = 1 if employment==.
tab missing_employment

*Marital Status
tab mstatus
tab mstatus, nolabel
recode mstatus (2/3=1 "Married or Partnered") (1=0 "Unmarried or Unpartnered") (4/8=0 "Unmarried or Unpartnered")(9=.), gen(marital)
label variable marital "Marital Status"
tab mstatus marital, col m

gen missing_marital = 0
replace missing_marital = 1 if marital==.
tab missing_marital

*Political Party
tab polview
tab polview, nolabel
*recode polview (1/2=0 "Republican") (3/5=1 "Democrat") (8/9=.), gen(pparty)
*label variable pparty "Political Party"
*tab polview pparty

recode polview (1=0 "Republican") (4/5=1 "Democrat") (2/3=2 "Not a Republican or Democrat") (8/9=.), gen(pparty)
label variable pparty "Political Party"
tab polview pparty

gen missing_pparty = 0
replace missing_pparty = 1 if pparty==.
tab missing_pparty

*Registered Voter
tab regvote
tab regvote, nolabel
tab regvote citizen, missing
recode regvote (1=1 "Registered Voter") (2=0 "Not a Registered Voter") (8/9=.), gen(registeredvoter)
label variable registeredvoter "Voter Registration Status"
tab registeredvoter citizen
replace registeredvoter=0 if citizen==0&regvote!=8
tab registeredvoter citizen
tab registeredvoter, missing

gen missing_registeredvoter = 0
replace missing_registeredvoter = 1 if registeredvoter==.
tab missing_registeredvoter

*Census Region of Residence
tab region
rename region census_region_res

*Educational Attainment
tab educ
tab educ, nolabel
recode educ (1/2=0 "< High School") (3=1 "High School") (4/5=2 "Some College") (6/8=3 "College+") (98=.)(99=.), gen(educ2)
tab educ educ2
drop educ
gen educ=educ2
drop educ2
label define educ_labels 0 "< High School"  1 "High School" 2 "Some College"  3 "College+"  9 "Unknown or Refused Education", replace
label values educ educ_labels
tab educ

gen missing_educ = 0
replace missing_educ = 1 if educ==.
tab missing_educ

gen svy_year = 2016
rename popwght svy_weight
gen svy_weight2 = svy_weight*((0.1667)/(0.1160))
label variable svy_year "Year of Survey"

**Additional Controls
*Children in Household 
tab kids1217
tab kids1217, nolabel
tab kids611, missing
tab kids611, nolabel
tab kidsless6
tab kidsless6, nolabel
tab  kids1217 parent, missing nolabel

gen child18=.
replace child18=1 if kids1217>0&kids1217<5 & child18==.
replace child18=1 if kids611>0&kids611<5 & child18==.
replace child18=1 if kidsless6>0&kidsless6<5. & child18==.
replace child18=0 if kids1217==0& kids611==0& kidsless6==0 
replace child18=. if kids1217==.& kids611==.& kidsless6==.
label variable child18 "Child under 18 in Household"
label define child18_labs 1 "Child under 18 in HH"  0 "No children in HH" 2 "Unknown or Refused Children in HH", replace
label values child18 child18_labs
tab child18, m
tab child18 parent, missing

replace parent =1 if child18==1 & parent==.

gen missing_child18 = 0
replace missing_child18 =1 if child18== .
tab missing_child18

recode kids611 (1/4=1 "Kids under 6 in HH") (0=0 "No Kids Under 6 in HH") (2=.), gen(child6)
label variable child6 "Child under 6 in household present"
tab kids611 child6, missing

*Household Adults
rename adults hh_adults
replace hh_adults = . if hh_adults==9

gen missing_hh_adults = 0
replace missing_hh_adults = 1 if hh_adults==.
tab missing_hh_adults

**Robustness Checks
*overall deportation rate
gen deportations_overall = .
replace deportations_overall = (332227/22214947)

*interior deportation rate
*using FY/noncitizen population
gen deportations_interior = .
replace deportations_interior = (65332/22214947)

*google trends
gen gtrends_deport = .
replace gtrends_deport = 100

* News articles mentioning "deport*"
	*Use data from months encompassing the Pew survey, divided by the total number of months for 
	///each survey and normalized to 100

gen news = .
replace news = 100
label variable news "News Mentions of Deport*"

*** Keep ---------------

keep id worry worry2 census_region_res svy_weight citizen nativity legal_status age sex hhsize hhincome educ employment marital parent pparty registeredvoter  svy_year svy_weight hh_adults child6 deportations_interior gtrends_deport deportations_overall svy_weight2 news


save "2016_clean.dta", replace












*****2018 DATA-----------------------------------------------------------------------------
use "2018.dta", clear

***Rename Variables ------------------------
* Case Identifier
rename case_id id

* Main Dependent Variable
tab qn24
tab qn24, nolabel

recode qn24 (1=3 "Worries a lot about deportation") (2=2 "Worries some about deportation") (3=1 "Doesn't worry much about deportation") (4=0 "Doesn't worry at all about deportation") (8/9 =.), gen(worry)
label variable worry "Deportation Worries (ordered)"
tab worry, m

recode qn24 (1/2=1 "Worries a lot/some about deportation") (3/4=0 "Doesn't worry much/at all about deportation")  (8/9 =. ), gen(worry2)
tab worry2, m
label variable worry2 "Deportation Worries (binary)"

recode qn24 (1/4=0 "Answered") (8/9=1 "Refused/don't know"), gen(worry_missing)
label variable worry_missing "Deportation Worries (missing=1, non-missing=0)"

**Main Independent Variables
*All Citizens v. All Noncitizens

tab qn9
tab qn9, nolabel
recode qn9 (1=1 "U.S. Citizens") (2=0 "Noncitizens")  (9 = .), gen(citizen)
label variable citizen "Are you a citizen of the US?"
tab citizen

rename qn4 bornusa
rename qn33 greencard

replace citizen = 1 if bornusa==1 | bornusa==2

tab citizen, missing
tab citizen, nolabel 

tab bornusa
tab bornusa, nolabel

tab bornusa citizen, missing

*All Foreign Born v. All US Born
*us born = 0, foreign born = 1
gen nativity=.
replace nativity=0 if bornusa==1
replace nativity=0 if bornusa==2
replace nativity=1 if bornusa==3
replace nativity=. if bornusa==9

replace citizen = 1 if nativity==0

label define nativity_lab 1 "Foreign Born"  0 "U.S. Born" , replace
label values nativity nativity_lab
label variable nativity "Foreign Born vs U.S. Born"
tab nativity, missing


tab greencard
tab greencard, nolabel

tab greencard nativity, missing
tab greencard citizen, missing

*Legal Status
gen legal_status=.
replace legal_status=1 if nativity==0   
replace legal_status=2 if citizen==1 & nativity==1

replace legal_status=3 if citizen==0 & nativity==1 & greencard==1
replace legal_status=3 if citizen==9 & nativity==1 & greencard==1

replace legal_status=4 if citizen==0 & nativity==1 & greencard==2
replace legal_status=4 if citizen==0 & nativity==1 & greencard==8
replace legal_status=4 if citizen==0 & nativity==1 & greencard==9
replace legal_status=4 if citizen==9 & nativity==1 & greencard==8
replace legal_status=4 if citizen==9 & nativity==1 & greencard==9
replace legal_status=4 if citizen==9 & nativity==1 & greencard==2
replace legal_status=4 if citizen==9 & nativity==1 & greencard==.

label define l_status 1 "U.S.-born Citizens"  2 "Naturalized Citizens" 3 "Lawful Permanent Residents" 4 "Likely-Undocumented"  
label values legal_status l_status
label variable legal_status "Legal Status (4 level)"
tab legal_status, missing

replace citizen = 1 if legal_status==1 & citizen==.
replace citizen =1 if legal_status==2 & citizen==.
replace citizen =0 if legal_status==3 & citizen==.
replace citizen =0 if legal_status==4 & citizen==.
tab citizen, m

tab citizen legal_status, col m
tab citizen nativity, col m

gen missing_legal_status =0
replace missing_legal_status =1 if legal_status==.
tab missing_legal_status

**Main Controls
*Age
tab age
tab age, nol
recode age (99=.)

gen missing_age=0 
replace missing_age=1 if age==.
tab age missing_age, missing

*Sex
rename sex Sex
recode Sex (1=0 "Male") (2=1 "Female"), gen(sex)
tab sex, m
tab sex, nol

*Household Size
tab hh1
tab hh1, nolabel
recode hh1 (1/4=0 "< 5 People in HH") (5/8=1 "> 4 People in HH") (9=.), gen (hhsize)
label variable hhsize "Household Size"
tab hh1 hhsize

gen missing_hhsize =0
replace missing_hhsize = 1 if hhsize==.
tab missing_hhsize

*Financial Situation
tab qn12a
recode qn12a (4=0 "Poor financial situation") (3=1 "Fair financial situation") (2=2 "Good financial situation") (1=3 "Excellent financial situation") (8/9=.), gen(hhincome2)
label define hhincome2_lab 0 "Poor Financial Situation" 1 "Fair Financial Situation" 2 "Good Financial Situation"3 "Excellent Financial Situation" 9 "Unknown or Refused Financial Situation", replace
label values hhincome2 hhincome2_lab

gen missing_hhincome2 = 0
replace missing_hhincome2 = 1 if hhincome2==.
tab missing_hhincome2

*Household Income
tab income
tab income, nolabel
recode income (1/5=0 "HH Income < $50,000") (6/9=1 "HH Income > $50,000")  (98/99=.), gen(hhincome)
label variable hhincome "Income"
tab hhincome
tab  income hhincome

gen missing_hhincome = 0
replace missing_hhincome = 1 if hhincome==.
tab missing_hhincome 

*Employed
tab qnemploy2
tab qnemploy2, nolabel
recode qnemploy2 (1=1 "Employed") (5=1 "Employed") (2=1 "Employed") (3/4=0 "Unemployed") (5/7=0 "Unemployed") (8/99=.), gen(employment)
label variable employment "Employment Status"
tab employment

gen missing_employment = 0
replace missing_employment = 1 if employment==.
tab missing_employment

*Marital Status
tab marital
tab marital, nolabel
recode marital (1/2=1 "Married or Partnered") (3/6=0 "Unmarried or Upartnered")(8/9 = .), gen(marital2)
drop marital
gen marital=marital2
drop marital2
label define marital_labels 1 "Married or Partnered"  0 "Unmarried or Unpartnered" , replace
label values marital marital_labels
label variable marital "Marital Status"
tab marital

gen missing_marital = 0
replace missing_marital = 1 if marital==.
tab missing_marital

*Parental Status
tab parent, missing
tab parent, nolabel
recode parent (1=1 "Parent") (2=0 "Not a Parent")(8/9=.), gen(parent2)
tab parent parent2, missing
drop parent
gen parent=parent2
tab parent
drop parent2
label define parent_labels 1 "Parent"  0 "Not a Parent" , replace
label values parent parent_labels
tab parent

gen missing_parent = 0
replace missing_parent = 1 if parent==.
tab missing_parent

*Political Party
tab party
tab party, nolabel
recode party (1=0 "Republican") (2=1 "Democrat") (3/5=2 "Not a Republican or Democrat")(8/9=.), gen(pparty)
label variable pparty "Political Party"
tab party pparty

gen missing_pparty = 0
replace missing_pparty = 1 if pparty==.
tab missing_pparty

*Registered Voters
tab reg
tab reg, nolabel
tab reg citizen, missing
*There are 14 people that are not citizens, but are registered to vote
recode reg (1/2=1 "Registered Voter") (3/4=0 "Not a Registered Voter") (8/9=.) (.=.), gen(registeredvoter)
replace registeredvoter=0 if citizen==0
label variable registeredvoter "Voter Registration Status"
tab registeredvoter, missing

gen missing_registeredvoter = 0
replace missing_registeredvoter = 1 if registeredvoter==.
tab missing_registeredvoter

*Years Lived USA
tab qn6, missing
tab qn6, nolabel
tab qn6yr
tab qn6mnth
tab qn6year

tab qn6 bornusa, missing
tab age, missing

gen yearslivedusa=qn6yr
tab yearslivedusa
replace yearslivedusa=qn6mnth/12 if qn6==2 
replace yearslivedusa=age if bornusa==2
replace yearslivedusa=2018-qn6year if qn6==3
replace yearslivedusa=0 if yearslivedusa<1 & yearslivedusa !=.
tab yearslivedusa, missing
label variable yearslivedusa "Years Lived in USA"

gen missing_yrs=0 
replace missing_yrs=1 if yearslivedusa==.

tab yearslivedusa
tab yearslivedusa, nolabel

*Survey Language
tab qn101
tab qn101, nolabel
recode qn101 (1/3=1 "Spanish Survey") (4/5=0 "English Survey"), gen(intvlanguage)
tab intvlanguage

*Birthplace
tab qn5, missing
tab qn5 nativity, missing
tab qn5, nolabel
recode qn5 (.=0 "Born in USA")  (24=0 "Born in USA") (18=1 "Born in Mexico") (12=2 "Born in Central America")(17=2 "Born in Central America") (14=2 "Born in Central America") (1/11=3 "Born Outside USA, Mexico, Central America") ///
(13=3 "Born Outside USA, Mexico, Central America")(15/16=3 "Born Outside USA, Mexico, Central America") (18/23=3 "Other") (24/99=3 "Born Outside USA, Mexico, Central America"), gen(birthcountry)
tab qn5 birthcountry, missing
label variable birthcountry "Country of Birth"

*Educational Attainment
tab educ
tab educ, nolabel
recode educ (1/2=0 "< High School") (3=1 "High School") (4/5=2 "Some College") (6/8=3 "College+") (98=.)(99=.), gen(educ2)
tab educ educ2
drop educ
gen educ=educ2
drop educ2
label define educ_labels 0 "< High School"  1 "High School" 2 "Some College"  3 "College+"  9 "Unknown or Refused Education", replace
label values educ educ_labels
tab educ

gen missing_educ = 0
replace missing_educ = 1 if educ==.
tab missing_educ

*Census Region Residence
rename samp020 census_region_res
gen svy_year = 2018
rename weight svy_weight
gen svy_weight2 = svy_weight*((0.1667)/(0.1742))
label variable svy_year "Year of Survey"

**Additional Controls
*Household Adults
tab hh3, missing

rename hh3 hh_adults
replace hh_adults =. if hh_adults==9

gen missing_hh_adults = 0
replace missing_hh_adults = 1 if hh_adults==.
tab missing_hh_adults

*Mother's Birthplace
tab qn7
tab qn7, nolabel missing
tab bornusa, missing
tab bornusa, nolabel
tab qn7 bornusa, missing
tab qn7 bornusa, missing nolabel

recode qn7 (1/2=0 "Mother Born in USA")  (3=1 "Mother Born Outside USA") (8/9=.), gen(m_born)
label variable m_born "Mother Born Outside the USA"
replace m_born=1 if bornusa==3
tab m_born, missing

gen missing_m_born = 0
replace missing_m_born = 1 if m_born==.
tab missing_m_born

*Father's Birthplace
tab qn8
tab qn8, nolabel missing
recode qn8 (1/2=0 "Father Born in USA")  (3=1 "Father Born Outside USA") (8/9=.), gen(f_born)
label variable f_born "Father Born Outside the USA"
replace f_born=1 if bornusa==3
tab f_born, missing

gen missing_f_born = 0
replace missing_f_born = 1 if f_born==.
tab missing_f_born

*Parents' Birthplace
gen parentborn=.
replace parentborn=0 if m_born==0&f_born==0
replace parentborn=1 if m_born==1|f_born==1
label variable parentborn "Was one of your parents born outside USA or Puerto Rico"
label define parentborn_labs 0 "No Foreign Born Parent"  1 "Foreign Born Parent" 2 "Unknown or Refused Foreign Born Parent" , replace
label values parentborn parentborn_labs

tab parentborn, missing

gen missing_parentborn = 0
replace missing_parentborn = 1 if parentborn==.
tab missing_parentborn

tab m_born f_born if parentborn==0
tab m_born f_born if parentborn==1
tab m_born f_born if parentborn==.

tab citizen parentborn, col m

**Robustness Checks
*Discrimination 
*In past 12 months, personally experienced race/ethnic discrimination?
fre qn23f
recode qn23f (1=1 "Yes, experienced race/ethnic discrimination") (2=0 "No, haven't experienced race/ethnic discrimination") (8/9 =.), gen(discrimination)
label variable discrimination "Race/Ethnic Discrimination"
fre discrimination

recode qn23f (1/2=0 "Answered") (8/9=1 "Not Answered") , gen(discrimination_missing)
fre discrimination_missing

*Heritage 
fre qn3
recode qn3 (8/97 = 0 "Not Mexican/CA")(1=1 "Mexican or Central American") (2/4 = 0 "Not Mexican/CA") (5 = 1 "Mexican or Central American") (6 = 0 "Not Mexican/CA") (7 = 1 "Mexican or Central American") (98/99 = .), gen(heritage)
tab heritage, m
label variable heritage "Family Heritage"

fre qn3oth
replace heritage = 0 if heritage==. & qn3oth==14 | qn3oth==17 | qn3oth==19
replace heritage = 0 if heritage==. & qn3oth==30
replace heritage = 0 if heritage==. & qn3oth != 14 & qn3oth !=17 & qn3oth !=19 & qn3oth !=30 & qn3oth != 98 & qn3oth !=99

gen heritage_missing = 0
replace heritage_missing=1 if heritage==.

*Google Trends
gen gtrends_deport = .
replace gtrends_deport = 74.2

*overall deportation rate
gen deportations_overall = .
replace deportations_overall = (337287/22289490)

*interior deportation rate
*using  FY/noncitizen population
gen deportations_interior = .
replace deportations_interior = (95360/22289490)

* News articles mentioning "deport*"
	*Use data from months encompassing the Pew survey, divided by the total number of months for 
	///each survey and normalized to 100

gen news = .
replace news = 83.2
label variable news "News Mentions of Deport*"

*** KEEP -----------------------------------------------------


keep id worry worry2 m_born f_born parentborn legal_status hhincome2 citizen nativity age sex hhsize hhincome educ employment marital parent pparty registeredvoter yearslivedusa  intvlanguage birthcountry census_region_res svy_year svy_weight hh_adults discrimination discrimination_missing heritage heritage_missing gtrends_deport  deportations_interior deportations_overall svy_weight2 news


save "2018_clean.dta",replace





***COMBINING THE DATASETS------------------------------------------
 
 
 
 use "2018_clean.dta", clear
append using "2016_clean.dta"
append using "2013_clean.dta"
append using "2010_clean.dta"
append using "2008_clean.dta"
append using "2007_clean.dta"


label variable hh_adults "Number of Adults in Household"

label variable sex "Sex"
label variable intvlanguage "Interview Language"
label variable age "Age"
label variable educ "Level of Education"
label variable gtrends_deport "Google Trends - Deportation"
label variable deportations_overall "Overall Deportation Rate"
label variable deportations_interior "Interior Deportation Rate"
label variable parent "Parental Status (1 = yes a parent)"
label variable heritage_missing "Heritage = Missing"

recode svy_year (2007/2008=0 "Bush") (2010/2016=1 "Obama") (2018=2 "Trump"), gen(president)
label variable president "Presidential Administration"
tab president, m

gen deportations_overall2 = (deportations_overall*100000)
label variable deportations_overall2 "Deportation Rate per 100K Noncitizens"


save "pew_data_allyrs.dta", replace



***GO TO 2-missingdata_010320 FILE NOW***


